package com.zpark.controller;

import com.zpark.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.xml.crypto.Data;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: Swagger2Controller
 * @Description:
 * @author: RZS
 * @date: 2022/10/18  11:04
 */
@RestController
@Api(tags = "这是swagger2接口类")
public class Swagger2Controller {

    @RequestMapping("/d1")
    @ApiOperation("这是demo01方法")
    public String demo01(){
        return "demo01方法";
    }

    @GetMapping("/d2")
    @ApiOperation("这是包含一个参数的请求方法")
    @ApiImplicitParam(name = "username", value = "用户名字", required = true, dataType = "String")
    public String demo02(String username){
        return "{这是名字："+username+"}";
    }

    @PostMapping("/d3")
    @ApiOperation("这是包含三个请求参数的方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uname", value = "用户名字", required = true, dataType = "String"),
            @ApiImplicitParam(name = "pwd", value = "用户密码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "id", value = "用户ID", required = true)
    })
    public User demo03(String uname, String pwd, Integer id){
        return new User(id, uname, pwd, null);
    }

    @DeleteMapping("/d4")
    @ApiOperation("这是包含一个user参数的请求方法")
    @ApiImplicitParam(name = "user", value = "用户对象user", required = true)
    public User demo04(User user){
        System.out.println(user);
        return user;
    }
}
